package com.itstudy.common;

import com.alibaba.fastjson.JSON;

import java.io.IOException;

/**
 * @ClassName: JSONSerializer
 * @Auther: Jerry
 * @Date: 2020/8/18 22:33
 * @Desctiption: TODO
 * @Version: 1.0
 */
public class JSONSerializer implements Serializer{
    @Override
    public byte[] serialize(Object object) throws IOException {
        return JSON.toJSONBytes(object);
    }

    @Override
    public <T> T deserialize(Class<T> clazz, byte[] bytes) throws IOException {
        return JSON.parseObject(bytes, clazz);
    }
}
